import qbs

Project {
    CppApplication {
        consoleApplication : false
        Group {
                name: "The App itself"
                fileTagsFilter: "application"
                qbs.install: true
                qbs.installDir: "bin"
            }
        Depends { name: "Qt"; submodules: [ "core", "gui", "widgets","concurrent","serialport","network" ]}
        Depends { name: "utils"}
        Depends { name: "qlogger"}

        name : "wind_calc"

        targetName : {

            if(qbs.buildVariant == "debug")
                return "wind_calcd"
            else
                return "wind_calc"
        }

        Group{
            name : "src"
            prefix : "src/"
            files:[
                "*.hpp",
                "*.cpp"
            ]
        }
        Group{
            name : "ui"
            prefix : "src/"
            files:["*.ui"]
        }

        Group{
            name:"x_res"
            files:["*.qrc","*rc"]
        }

        Group{
            name: "transform"
            prefix: "../dsp_lab/src/"
            files:["transformwindow.hpp","transformwindow.cpp","ui/transformwindow.ui"]
        }

        Group{
            name: "plot"
            prefix: "../dsp_lab/src/plot/"
            files:["qwtchartzoom.h","qwtchartzoom.cpp","plot.cpp","plot.hpp"]
        }
        Group{
            name: "data_object"
            prefix: "../dsp_lab/src/dataobject/"
            files:["*.hpp","*.cpp"]
        }
        Group{
            name: "x_other"
            files: ["*.txt"]
        }

        cpp.cxxFlags:{
            var flags = base
            if(cpp.compilerName.contains("g++"))
                flags = flags.concat(["-std=gnu++11"])
            return flags
        }

        cpp.defines : {
            var def = base
            if(qbs.buildVariant == "debug") {
                def = def.concat(["LOG_LEVEL=127","QT_SHAREDPOINTER_TRACK_POINTERS"])
            }
            else {
                def = def.concat(["LOG_LEVEL=127"])
            }

            return def
        }

        cpp.includePaths : {
            var inc = base.concat(["src", "src/plot","src/generator","src/plot","../dsp_lab/src","../dsp_lab/src/plot","../dsp_lab_plugins/utils/include"])
            if(qbs.hostOS.contains("windows")){
                inc = inc.concat(["d:/projects/cpplibs/qwt_trunk/qwt-code/qwt/src"])
            }
            else if(qbs.hostOS.contains("linux")){
                inc = inc.concat(["/home/alex/projects/cpplibs/qwt/qwt-code/qwt/src/",
                                  "/home/alex/projects/cpplibs/qwt-code/qwt/src"])
            }

            if(qbs.hostOS.contains("linux")) {
                if(qbs.architecture === "arm"){
                    inc = inc.concat(["/home/user/crosscompiler/raspbian_tools/rootfs/usr/include"]);
                }
                else{
                    inc = inc.concat(["~/projects/cpplibs/boost_1_56_0/"]);
                }
            }
            else if (qbs.hostOS.contains("windows")) {
                inc = inc.concat(["d:/projects/cpplibs/boost_1_56_0"]);
            }

            return inc
        }

        cpp.libraryPaths:{
            var lib_paths = base
            if(qbs.hostOS.contains("windows")){
                lib_paths = lib_paths.concat(["d:/projects/cpplibs/qwt_trunk/qwt-code/qwt/lib"])
            }
            else if(qbs.hostOS.contains("linux")){
                lib_paths = lib_paths.concat(["/home/alex/projects/cpplibs/qwt/qwt-code/qwt/lib/",
                                              "/home/alex/projects/cpplibs/qwt-code/qwt/lib"])
            }

            return lib_paths
        }

        cpp.dynamicLibraries:{
            var dyn_libs = base
            var lib_suffix = ""
            if(qbs.buildVariant == "debug")
                lib_suffix = "d"
            dyn_libs = dyn_libs.concat(["qlogger"+lib_suffix])
            if(qbs.hostOS.contains("linux"))
                dyn_libs = dyn_libs.concat(["qwt"])
            else
                dyn_libs = dyn_libs.concat(["qwt"+lib_suffix])

            return dyn_libs
        }

        cpp.rpaths : {
            var rpath = base
            if(qbs.hostOS.contains("linux")) {
                rpath = rpath.concat(["/home/alex/projects/cpplibs/qwt/qwt-code/qwt/lib/",
                                      "/home/alex/projects/cpplibs/qwt-code/qwt/lib",
                                      "/home/alex/projects/cpplibs/qlogger/lib/linux-g++/5.3.1/",
                                      "/home/alex/projects/cpplibs/qlogger/lib/linux-g++/5.3.2/"])
            }
            return rpath
        }
    }
}
